package feedback.core.models.entities; /***********************************************************************
 * Module:  Answer.java
 * Author:  lufy
 * Purpose: Defines the Class Answer
 ***********************************************************************/

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@SuppressWarnings("serial")
@Entity
public class Answer implements Serializable{
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private int answerId;
   private int answerScore;
   @ManyToOne(fetch = FetchType.LAZY,  cascade = { CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
   @JoinColumn(name = "srId",nullable = false)
   private SurveyResult surveyResult;
   @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
   @JoinColumn(name = "questionId",nullable = false )
   private Question question;

   public Answer() {
   }

   public Answer(int answerScore, SurveyResult surveyResult, Question question) {
      this.answerScore = answerScore;
      this.surveyResult = surveyResult;
      this.question = question;
   }

   public int getAnswerId() {
      return answerId;
   }

   public void setAnswerId(int answerId) {
      this.answerId = answerId;
   }

   public int getAnswerScore() {
      return answerScore;
   }

   public void setAnswerScore(int answerScore) {
      this.answerScore = answerScore;
   }

   public SurveyResult getSurveyResult() {
      return surveyResult;
   }

   public void setSurveyResult(SurveyResult surveyResult) {
      this.surveyResult = surveyResult;
   }

   public Question getQuestion() {
      return question;
   }

   public void setQuestion(Question question) {
      this.question = question;
   }
}